import { Request, Response } from "express";

const express = require("express");
const bodyParser = require("body-parser");
const userController = require("./controllers/userController.ts")
const app = express();

const userRouter = require('./routers/userRouter.ts')
const port = process.env.PORT || 10246;

// 设置静态文件目录
app.use(express.static("public"));

// 使用body-parser中间件解析请求体
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());

// --------- 其他中间件和路由设置将在这里添加  -------

app.use('/user', userRouter)

// ----------- 其他中间件和路由设置将在这里添加   --------------

// 错误处理中间件
app.use((err: any, req: any, res: any, next: any) => {
  console.error(err.stack);
  res.status(500).send("Something broke!");
});

// 启动服务器
app.listen(port, () => {
  console.log(`Server is running on port ${port}`);
});
